const Ajv = require('ajv')
const localize = require('ajv-i18n')

// 规定校验类型
const schema = {
  type: "object",
  properties: {
    // 属性
    get: {
      type: "object", // 类型
      properties: {
        url: {
          type: "string",
        },
        method: {
          type: "string",
        },
      },
      required: ["url"], // 必须包含 url 属性
    },
  },
};
const data = {
  get: {
    aaa: "test"
  }
}


const ajv = new Ajv()
const validate = ajv.compile(schema)
const valid = validate(data)
if (!valid) {
  localize.zh(validate.errors)
  console.log(validate.errors)
}
